(function() {
  app.directive('confirmTip', function() {
    return {
      restrict: 'EA',
      templateUrl: 'public/directive/confirm.html',
      scope: {
        sourceObj: '=',
        type: '=',
        selected: '=', // 选择的所有结果
        confirmview: '=', // 控制视图显示
        close_flag: '=flag', // 执行多级菜单的标志
        callb: '&', // 二级菜单的数据渲染函数
        selectedTitle: '@title'
      },
      controller: function($scope) {

        $scope.item_click = function(item) {
          var copy = angular.copy(item);
          $scope.selected[$scope.type] = copy.text;
          if (copy.hasOwnProperty('param')) {
            $scope.selected.param = copy.param;
          }

          if ($scope.close_flag) {
            $scope.confirmview = false;
          } else {
            $scope.callb();
          }
        };

        $scope.confirmview = false;

      },
      link: function(scope, ele, atr) {}
    };
  });

})();